home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / gpg-zip < prev    next >
Encoding:
Text File  |  2007-03-07  |  3.3 KB  |  143 lines

  1. #!/bin/sh
  2.  
  3. # gpg-archive - gpg-ized tar using the same format as PGP's PGP Zip.
  4. # Copyright (C) 2005 Free Software Foundation, Inc.
  5. #
  6. # This file is part of GnuPG.
  7. #
  8. # GnuPG is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # GnuPG is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  21.  
  22. # Despite the name, PGP Zip format is actually an OpenPGP-wrapped tar
  23. # file.  To be compatible with PGP itself, this must be a USTAR format
  24. # tar file.  Unclear on whether there is a distinction here between
  25. # the GNU or POSIX variant of USTAR.
  26.  
  27. VERSION=1.4.6
  28. TAR=/bin/tar
  29. GPG=gpg
  30.  
  31. usage="\
  32. Usage: gpg-zip [--help] [--version] [--encrypt] [--decrypt] [--symmetric]
  33.        [--list-archive] [--output FILE] [--gpg GPG] [--gpg-args ARGS]
  34.        [--tar TAR] [--tar-args ARGS] filename1 [filename2, ...]
  35.        directory1 [directory2, ...]
  36.  
  37. Encrypt or sign files into an archive."
  38.  
  39. while test $# -gt 0 ; do
  40.   case $1 in
  41.     -h | --help | --h*)
  42.       echo "$usage"
  43.       exit 0
  44.       ;;
  45.     --list-archive)
  46.       list=yes
  47.       create=no
  48.       unpack=no
  49.       shift
  50.       ;;
  51.     --encrypt | -e)
  52.       gpg_args="$gpg_args --encrypt"
  53.       list=no
  54.       create=yes
  55.       unpack=no
  56.       shift
  57.       ;;
  58.     --decrypt | -d)
  59.       gpg_args="$gpg_args --decrypt"
  60.       list=no
  61.       create=no
  62.       unpack=yes
  63.       shift
  64.       ;;
  65.     --symmetric | -c)
  66.       gpg_args="$gpg_args --symmetric"
  67.       list=no
  68.       create=yes
  69.       unpack=no
  70.       shift
  71.       ;;
  72.     --sign | -s)
  73.       gpg_args="$gpg_args --sign"
  74.       list=no
  75.       create=yes
  76.       unpack=no
  77.       shift
  78.       ;;
  79.     --recipient | -r)
  80.       gpg_args="$gpg_args --recipient $2"
  81.       shift
  82.       shift
  83.       ;;
  84.     --local-user | -u)
  85.       gpg_args="$gpg_args --local-user $2"
  86.       shift
  87.       shift
  88.       ;;
  89.     --output | -o)
  90.       gpg_args="$gpg_args --output $2"
  91.       shift
  92.       shift
  93.       ;;
  94.     --version)
  95.       echo "gpg-zip (GnuPG) $VERSION"
  96.       exit 0
  97.       ;;
  98.     --gpg)
  99.       GPG=$1
  100.       shift
  101.       ;;
  102.     --gpg-args)
  103.       gpg_args="$gpg_args $2"
  104.       shift
  105.       shift
  106.       ;;
  107.     --tar)
  108.       TAR=$1
  109.       shift
  110.       ;;
  111.     --tar-args)
  112.       tar_args="$tar_args $2"
  113.       shift
  114.       shift
  115.       ;;
  116.     --)
  117.       shift
  118.       break
  119.       ;;
  120.     -*)
  121.       echo "$usage" 1>&2
  122.       exit 1
  123.       ;;
  124.     *)
  125.       break
  126.       ;;
  127.   esac
  128. done
  129.  
  130. if test x$create = xyes ; then
  131. #   echo "$TAR -cf - "$@" | $GPG --set-filename x.tar $gpg_args" 1>&2
  132.    $TAR -cf - "$@" | $GPG --set-filename x.tar $gpg_args
  133. elif test x$list = xyes ; then
  134. #   echo "cat \"$1\" | $GPG $gpg_args | $TAR $tar_args -tf -" 1>&2
  135.    cat "$1" | $GPG $gpg_args | $TAR $tar_args -tf -
  136. elif test x$unpack = xyes ; then
  137. #   echo "cat \"$1\" | $GPG $gpg_args | $TAR $tar_args -xvf -" 1>&2
  138.    cat "$1" | $GPG $gpg_args | $TAR $tar_args -xvf -
  139. else
  140.    echo "$usage" 1>&2
  141.    exit 1
  142. fi
  143.